"""
File: user.py
Author: ershixiong
Date: 2023/12/12
describe:

"""
from jsonpath import jsonpath

from project202311_wework.wework.frame.apis.wework import Wework


class User(Wework):

    def create(self, data):
        url = 'user/create'

        req = {
            'method': 'POST',
            'url': url,
            'json': data
        }
        r = self.send_api(req)
        return r

    def list(self):
        url = 'user/list_id'

        req = {
            'method': 'POST',
            'url': url,
        }
        r = self.send_api(req)
        return r

    def update(self, data):
        url = 'user/update'

        req = {
            'method': 'POST',
            'url': url,
            'json': data
        }
        r = self.send_api(req)
        return r

    def delete(self, userid):
        url = 'user/delete'
        params = {
            'userid': userid
        }
        req = {
            'method': 'POST',
            'url': url,
            'params': params
        }
        r = self.send_api(req)
        return r

    def batchdelete(self, userids):
        url = 'user/batchdelete'

        req = {
            'method': 'POST',
            'url': url,
            'json': {"useridlist": userids}
        }
        r = self.send_api(req)
        return r

    def clear(self):
        list_r = self.list()
        userids = jsonpath(list_r.json(), '$..userid')
        for userid in userids:
            if userid != "LvKai":
                self.delete(userid)

    def userid_to_openid(self):
        pass

    def login_verify(self):
        pass

    def invite_user(self):
        pass

    def get_join_code(self):
        pass

    def get_userid_by_mobile(self):
        pass

    def get_userid_by_email(self):
        pass
